﻿@model cloudscribe.Core.Web.ViewModels.UserAdmin.ChangeUserPasswordViewModel
@inject ICoreThemeHelper themeHelper
@inject IStringLocalizer<CloudscribeCore> sr
@inject SiteContext siteContext
@{
    var themeSettings = themeHelper.GetThemeSettings();
    if (themeSettings.AdminSideNavExpanded) { ViewData["SideNavToggle"] = "show"; }
    ViewData["SideNavVisible"] = true;
}
<h2>@ViewData["Title"]</h2>
<h4>@Model.Email - @Model.DisplayName</h4>
<hr />
 @{
        if (ViewData.ModelState.IsValid && (siteContext.PwdRequireDigit || siteContext.PwdRequireLowercase || siteContext.PwdRequireNonAlpha || siteContext.PwdRequireUppercase))
        {
            <div class="mb-3">
                <ul>
                    <li>@sr["Password must be different from current password"]</li>
                    @if (siteContext.PwdRequireDigit) {
                    <li>@sr["Passwords must have at least one digit ('0'-'9')."]</li>
                    }

                    @if (siteContext.PwdRequireLowercase) {
                    <li>@sr["Passwords must have at least one lowercase character ('a'-'z')."]</li>
                    }

                    @if (siteContext.PwdRequireNonAlpha) {
                    <li>@sr["Passwords must have at least one non alphanumeric character"]</li>
                    }

                    @if (siteContext.PwdRequireUppercase) {
                    <li>@sr["Passwords must have at least one uppercase character ('A'-'Z')."]</li>
                    }
                </ul>
            </div>
        }
    }

<form asp-action="ChangeUserPassword">
    @*<div asp-validation-summary="ModelOnly" class="text-danger"></div>*@
    <input asp-for="UserId" type="hidden" />
    <input asp-for="SiteId" type="hidden" />

    <div class="mb-3">
        <label class="form-label" asp-for="NewPassword"></label>
        <input asp-for="NewPassword" class="form-control" data-val="true" data-val-length=@sr["The new password must be at least {0} characters long.", siteContext.MinRequiredPasswordLength] data-val-length-max="100" data-val-length-min="@siteContext.MinRequiredPasswordLength" data-val-required="New password is required" />
        <span asp-validation-for="NewPassword" class="invalid-feedback"></span>

    </div>
    <div class="mb-3">
        <label class="form-label" asp-for="ConfirmPassword"></label>
        <input asp-for="ConfirmPassword" class="form-control" />
        <span asp-validation-for="ConfirmPassword" class="invalid-feedback"></span>
    </div>
    <div class="mb-3">
        <div class="form-check">
            <input asp-for="MustChangePwd" class="form-check-input" />
            <label asp-for="MustChangePwd" class="form-check-label">@sr["User must change password"]</label>
        </div>
    </div>
   


    <div class="mb-3">
        <input type="submit" value="@sr["Save"]" class="btn btn-primary" />
    </div>
</form>

@section SideNav {
    @{ await Html.RenderPartialAsync("AdminSideNav"); }
}
@section Toolbar{
    @{ await Html.RenderPartialAsync("AdminSideNavToggle"); }
}
@section Scripts {
    @{ await Html.RenderPartialAsync("AdminSideNavScripts"); }
    @{await Html.RenderPartialAsync("_UnobtrusiveValidationScriptsPartial"); }
    <script src="~/cr/js/unobtrusive-validation-bs4.min.js"></script>
}
